package com.bilibili.lzx.dao.domain;

/**
 * @author lzx
 * @date 2024/8/6 21:16
 */
public class JsonResponse<T> {
    private String msg;
    private String code;
    private T data;


    public JsonResponse(String msg, String code) {
        this.msg = msg;
        this.code = code;
    }

    public JsonResponse(T data){
        this.data=data;
        this.msg="成功";
        this.code="200";
    }

    public static JsonResponse<String> success(String data){
       return new JsonResponse<>(data);
    }
    public static JsonResponse<String> success(){
        return new JsonResponse<>(null);
    }

    public static JsonResponse<String> fail(String msg,String code){
        return new JsonResponse<>(msg, code);
    }

    public static JsonResponse<String> fail(){
        return new JsonResponse<>("失败","404");

    }


    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
